<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>mixin</title>
</head>
<body>
<div id="app">{{hello()}} 日期：{{DataTime()}}</div>
<div id="vue"> 日期：{{DataTime()}}</div>
<script src="../vue.js"></script>
<script>
    var mymixin = {
        created:function(){
            this.hello();
        },
        methods:{
            hello(){
              return 'hello';
            },
            DataTime(){
                let dataNow = new Date(),
                    year = dataNow.getFullYear(),
                    months = dataNow.getMonth()+1,
                    bay = dataNow.getDate();
                months = String(months).padStart(2,'0');
                return `${year}-${months}-${bay}`;
            }
        }
    };
    new Vue({
        el:"#app",
        mixins:[mymixin]
    })
    new Vue({
        el:"#vue",
        mixins:[mymixin]
    })
</script>
</body>
</html>